package cn.chen.数据结构.图;

public class GraphTest {

    public static void main(String[] args){

        Graph graph=new Graph(8);
        String vertex[]={"1","2","3","4","5","6","7","8"};

        for(int i=0;i<vertex.length;i++){

            graph.addVertex(vertex[i]);
        }
        // 添加边：a-b,a-c,b-c,b-d,b-e
        graph.addEdge(0,1,1);   // a-b
        graph.addEdge(0,2,1);   // a-c
        graph.addEdge(1,3,1);   // b-c
        graph.addEdge(1,4,1);   // b-d
        graph.addEdge(3,7,1);   // b-e
        graph.addEdge(4,7,1);   // b-e
        graph.addEdge(2,5,1);   // b-e
        graph.addEdge(2,6,1);   // b-e
        graph.addEdge(5,6,1);   // b-e

        graph.showGraph();  // 遍历图

        graph.dfs();    // 深度优先搜索

        System.out.println();
        graph.bfs();    // 广度优先搜索
    }
}
